﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace RainingNight.MyBaseObject
{

    enum ID
    {
        TANK,
        BULLET,
        GUARD,
        FLASH,
        HYPERGUARD,
        BURST,
        BRICK,
        CONCRETE,
        GRASS,
        WATER,
    };

    public enum STATUS
    {
        NORMAL, DESTROY, ACTIVE,
        STUN, GUARDED, FLASH, HYPERGUARD, BURST// CTANK
    };

    abstract class MyObject
    {
        private ID m_ID;
        private Sprite m_Sprite;

        private Timer m_Timer;
        private float m_TimeUpdate;

        private STATUS m_Status;

        public MyObject(int col, Rectangle baserect,Vector2? position = null)
        {
            Sprite = new Sprite(col, baserect, position);
            Timer = new Timer();
            Status = STATUS.NORMAL;
            m_TimeUpdate = 0.0f;
            Sprite.Depth = 0.5f;
        }

        virtual public void Draw(SpriteBatch spritebatch)
        {
            this.setFrame();
            this.m_Sprite.Render(spritebatch);
        }

        virtual protected void setFrame()
        {
            Sprite.Frame = new Rectangle(
                Sprite.BaseRect.X + Sprite.CurFrame * Sprite.BaseRect.Width,
                Sprite.BaseRect.Y,
                Sprite.BaseRect.Width,
                Sprite.BaseRect.Height);
        }

        virtual public bool isCollision(MyObject obj)
        {
            return (this.Sprite.Bound.Intersects(obj.Sprite.Bound));
        }

        //abstract public void Update(GameTime gametime);

        #region Property

        public ID ID
        {
            get { return m_ID; }
            set { m_ID = value; }
        }

        public Sprite Sprite
        {
            get { return m_Sprite; }
            set { m_Sprite = value; }
        }

        public Timer Timer
        {
            get { return m_Timer; }
            private set { m_Timer = value; }
        }

        public STATUS Status
        {
            get { return m_Status; }
            set
            {
                m_Status = value;
            }
        }

        public float TimeUpdate
        {
            get { return m_TimeUpdate; }
            set { m_TimeUpdate = value; }
        }

        #endregion
    }
}
